#define _CRT_SECURE_NO_WARNINGS 1


#include <iostream>
#include<math.h>
#include<string>
#include<set>
using namespace std;

bool is_zhishu(int num) {
    for (int i = 2; i <= sqrt(num); i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}
int to_tranfer(string& s1)
{
    set<int> ss;
    int count = 0;
    string ret = "00";
    for (int i = 0; i < s1.size(); i++)
    {
        ret[0] = s1[i];
        for (int j = 0; j < s1.size(); j++)
        {
            if (i != j)
            {
                ret[1] = s1[j];
                if (ret[0] != '0')
                {
                    int num = stoi(ret);
                    ss.insert(num);
                }
            }
        }
    }
    for (auto n : ss)
    {
        if (is_zhishu(n))
        {
            return 1;
        }
    }

    return 0;
}

int main()
{
    int start = 0, end = 0;
    int sum = 0;
    cin >> start >> end;
    for (int i = start; i <= end; i++) {
        if(is_zhishu(i))
        {
            sum += 1;
        }
        else
        {
            string s1 = to_string(i);
            sum += to_tranfer(s1);
        }
       

    }
    cout << sum << endl;
    return 0;
}